<!DOCTYPE html>
<html>
<head>
    <title>job管理</title>
    <#include "/header.html">
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <div class="grid-btn">
            <a class="btn btn-default" @click="query">查询</a>
            <#if shiro.hasPermission("monitor:job:static:save")>
            <a class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>
        </#if>
        <#if shiro.hasPermission("monitor:job:static:update")>
        <a class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
    </#if>
    <#if shiro.hasPermission("monitor:job:static:delete")>
    <a class="btn btn-primary" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
</#if>
</div>
<table id="jqGrid"></table>
<div id="jqGridPager"></div>
</div>

<div v-show="!showList" class="panel panel-default">
    <div class="panel-heading">{{title}}</div>
    <form class="form-horizontal" style="width: 700px;">
        <div class="form-group">
            <div class="col-sm-2 control-label">任务名称</div>
            <div class="col-sm-10">
                <input type="text" class="form-control" v-model="job.job_name" placeholder="job名称"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">爬取间隔</div>
            <div class="col-sm-10">
                <input type="text" class="form-control" v-model="job.scrape_interval" placeholder="prometheus多久爬取一次数据"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">爬取超时</div>
            <div class="col-sm-10">
                <input type="text" class="form-control" v-model="job.scrape_timeout" placeholder="爬取超时"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">metric路径</div>
            <div class="col-sm-10">
                <input type="text" class="form-control" v-model="job.metrics_path" placeholder="metric路径,默认/metrics"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">请求协议</div>
            <div class="col-sm-10">
                <input type="text" class="form-control" v-model="job.scheme" placeholder="请求协议（http或https）"/>
            </div>
        </div>
        <!--targets-->
        <div class="form-group">
            <div class="col-sm-2 control-label">targets</div>
            <div class="panel panel-default col-sm-10">
                <div class="panel-body">
                    <div class="input-group" v-for="(item,index) in job.static_configs[0].targets">
                        <div class="input-icon-group">
                            <input type="text" class="form-control fc-clear" v-model="item" placeholder="ip:port" @change="setTarget(item,index)"/>
                        </div>
                        <span class="input-group-btn"><button class="btn btn-primary" type="button" @click="removeTarget(index)">移除</button></span>
                    </div>
                    <button type="button" class="btn btn-default btn-sm" @click="addTarget">
                        <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                    </button>
                </div>
            </div>
        </div>
        <!--标签 labels-->
        <div class="form-group">
            <div class="col-sm-2 control-label">labels</div>
            <div class="panel panel-default col-sm-10">
                <div class="panel-body">
                    <div class="input-group" v-for="(value,key) in job.static_configs[0].labels">
                        <span class="input-group-btn"><button class="btn btn-default" type="button">{{key}}</button></span>
                        <div class="input-icon-group">
                            <input type="text" class="form-control fc-clear" v-model="value" @change="modifyLabel(key,value)" placeholder="ip:port"/>
                        </div>
                        <span class="input-group-btn"><button class="btn btn-primary" type="button" @click="removeLabel(key)">移除</button></span>
                    </div>
                    <button type="button" class="btn btn-default btn-sm" @click="addLabel">
                        <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                    </button>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-3 control-label">使用数据时间戳</div>
            <label class="radio-inline">
                <input type="radio" name="status" value=true v-model="job.honor_timestamps"/> 是
            </label>
            <label class="radio-inline">
                <input type="radio" name="status" value=false v-model="job.honor_timestamps"/> 否
            </label>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"></div>
            <input type="button" class="btn btn-primary" @click="saveOrUpdate" value="确定"/>
            <input type="button" class="btn btn-warning" @click="reload" value="返回"/>
        </div>
    </form>
</div>
</div>

<script src="${request.contextPath}/statics/js/modules/monitor/job.js?_${.now?long}"></script>
</body>
</html>